layui.use(['form','layer','laydate','table','laytpl'],function(){
    var form = layui.form,
        layer = parent.layer === undefined ? layui.layer : top.layer,
        $ = layui.jquery,
        laydate = layui.laydate,
        laytpl = layui.laytpl,
        table = layui.table;

    //新闻列表
    var tableIns = table.render({
        elem: '#newsList',
        url : '/iprint/admin/getUnprintOrders',
        method:'get',
        request:{
        	 pageName: 'currPage' //页码的参数名称，默认：page
  			,limitName: 'pageSize' //每页数据量的参数名，默认：limit
        },
        response: {
		  statusName: 'status' //数据状态的字段名称，默认：code
		  ,statusCode: 200 //成功的状态码，默认：0
		  ,countName: 'totalCount' //数据总数的字段名称，默认：count
		  ,dataName: 'list' //数据列表的字段名称，默认：data
		},
        cellMinWidth : 95,
        page : true,
        height : "full-125",
        limit : 20,
        limits : [10,15,20,25],
        id : "newsListTable",
        cols : [[
            {title: '订单id', 	align:"center",field: 'id'},
            {title: '订单类型', 	align:'center',templet:"#newsStatus",field: 'title'},
            {title: '数量', 		align:'center',field: 'count'},
            {title: '总金额',  	align:'center',field: 'total'},
            {title: '纸张类型', 	align:'center',field: 'pageType'},
            {title: '纸张尺寸', 	align:'center',field: 'pageSize'},
            {title: '单双面', 	align:'center',field: 'singleDouble'},
            {title: '打印类型', 	align:'center',field: 'printType'},
            {title: '边距', 		align:'center',field: 'margin'},
            {title: '工艺', 		align:'center',field: 'craftwork', },
            {title: '底色', 		align:'center',field: 'changBgc'},
            {title: '纸张重量', 	align:'center',field: 'pageWeight'},
            {title: '操作', 		align:"center",width:180, templet:'#newsListBar',fixed:"right"}
        ]]
    });
    //列表操作
    table.on('tool(newsList)', function(obj){
        var layEvent = obj.event,
            data = obj.data;
        if(layEvent === 'download'){ //下载
        	//发送ID，查询数据库，下载文件
        	window.open("/iprint/admin/download?id="+data.id,'_blank');
        	
        } else if(layEvent === 'complated'){ 
            layer.confirm('确认完成该订单？！',{icon:3, title:'操作提示！'},function(index){
            	$.ajax({
            		url:"/iprint/admin/complated",
            		type:"get",
            		data:{id:data.id},
            		success:function(data){
            			tableIns.reload();
                        layer.close(index);
            		}
            	});
            	
            });
        } 
    });

})